﻿using System;
using System.Collections.Generic;

namespace SharpTag.ID3
{
    /// <summary>
    /// Concrete implementation of the <see cref="ITagExtendedHeader"/> interface.
    /// </summary>
    public class ID3V2TagExtendedHeader : ITagExtendedHeader
    {
        /// <summary>
        /// Class constructor.
        /// </summary>
        public ID3V2TagExtendedHeader()
        {
            Flags = new List<ExtendedHeaderFlag>();
            IsDirty = false;
        }

        /// <summary>
        /// Gets the Size of the ExtendedHeader.
        /// </summary>
        public long Size { get; private set; }

        /// <summary>
        /// Gets the Size of the Padding found in the Tag.
        /// </summary>
        public long SizeOfPadding { get; private set; }

        /// <summary>
        /// Gets the CRC data that is appended to the ExtendedHeader.
        /// </summary>
        public long TotalFrameCRC { get; private set; }

        /// <summary>
        /// Gets the list of <see cref="ExtendedHeaderFlag"/> objects that are set in the ExtendedHeader.
        /// </summary>
        public List<ExtendedHeaderFlag> Flags { get; private set; }

        /// <summary>
        /// Gets whether or not the ExtendedHeader has been modified.
        /// </summary>
        public bool IsDirty { get; private set; }

        /// <summary>
        /// Adds an <see cref="ExtendedHeaderFlag"/> object to the ExtendedHeader.
        /// </summary>
        /// <param name="flag">An <see cref="ExtendedHeaderFlag"/> object.</param>
        public void AddFlag(ExtendedHeaderFlag flag)
        {
            if (!Flags.Contains(flag))
                Flags.Add(flag);
        }

        /// <summary>
        /// Removes an <see cref="ExtendedHeaderFlag"/> object from the ExtendedHeader.
        /// </summary>
        /// <param name="flag"></param>
        public void RemoveFlag(ExtendedHeaderFlag flag)
        {
            if (Flags.Contains(flag))
                Flags.Remove(flag);
        }

        /// <summary>
        /// Converts the <see cref="ID3V2TagExtendedHeader"/> data into a byte array to be written out to the physical file.
        /// </summary>
        /// <returns>A byte array that contains the raw Tag data.</returns>
        public byte[] PrepareBytes()
        {
            throw new NotImplementedException();
        }
    }
}
